﻿﻿using System.Reflection;
using SqlSugar;

namespace JIESHINet.Repository.UnitOfWorks
{
    public interface IUnitOfWorkManage
    {
        SqlSugarScope GetDbClient();
        int TranCount { get; }

        UnitOfWork CreateUnitOfWork();
        /// <summary>
        /// 开始事务
        /// </summary>
        void BeginTran();
        /// <summary>
        /// 开始事务 并将方法信息推送到事务堆栈
        /// </summary>
        /// <param name="method"></param>
        void BeginTran(MethodInfo method);
        /// <summary>
        /// 提交事务
        /// </summary>
        void CommitTran();
        /// <summary>
        /// 提交事务，并根据方法信息判断是否成功提交
        /// </summary>
        /// <param name="method"></param>
        void CommitTran(MethodInfo method);
        /// <summary>
        /// 回滚事务
        /// </summary>
        void RollbackTran();
        /// <summary>
        /// 回滚事务，并根据方法信息判断是否成功回滚
        /// </summary>
        /// <param name="method"></param>
        void RollbackTran(MethodInfo method);
    }
}